require("dotenv").config();
const mongoose = require("mongoose");

const mongoURI = `mongodb://${process.env.DB_USERNAME}:${process.env.DB_PASSWORD}@${process.env.DB_HOST}:${process.env.DB_PORT}/${process.env.DB_NAME}?authSource=admin`;
(async function () {
  try {
    await mongoose.connect(mongoURI);
    console.log("数据库连接成功, 运行地址 " + mongoURI);
  } catch (error) {
    console.error("数据库连接失败:", error);
  }
})();
